<%-- 
    Document   : MenuUser
    Created on : Nov 18, 2011, 9:58:43 AM
    Author     : JackOddie
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@page import="Entities.*"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.util.GregorianCalendar"%>
<%@page import="java.util.Calendar"%>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Jadwal Penyewaan</title>
    <link href="style.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .tooltip
        {
            position: relative;
            background: #eaeaea;
            cursor: help;
            display: inline-block;
            text-decoration: none;
            color: #222;
            outline: none;
        }
        .tooltip span
        {
            visibility: hidden;
            position: absolute;
            bottom: 30px;
            left: 50%;
            z-index: 999;
            width: 230px;
            margin-left: -127px;
            padding: 10px;
            border: 2px solid #ccc;
            opacity: .9;
            background-color: #ddd;
            background-image: -webkit-linear-gradient(rgba(255,255,255,.5), rgba(255,255,255,0));
            background-image: -moz-linear-gradient(rgba(255,255,255,.5), rgba(255,255,255,0));
            background-image: -ms-linear-gradient(rgba(255,255,255,.5), rgba(255,255,255,0));
            background-image: -o-linear-gradient(rgba(255,255,255,.5), rgba(255,255,255,0));
            background-image: linear-gradient(rgba(255,255,255,.5), rgba(255,255,255,0));
            -moz-border-radius: 4px;
            border-radius: 4px;
            -moz-box-shadow: 0 1px 2px rgba(0,0,0,.4), 0 1px 0 rgba(255,255,255,.5) inset;
            -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.4), 0 1px 0 rgba(255,255,255,.5) inset;
            box-shadow: 0 1px 2px rgba(0,0,0,.4), 0 1px 0 rgba(255,255,255,.5) inset;
            text-shadow: 0 1px 0 rgba(255,255,255,.4);
        }
        .tooltip:hover
        {
            border: 0; /* IE6 fix */
        }
        .tooltip:hover span
        {
            visibility: visible;
        }
        .tooltip span:before,
        .tooltip span:after
        {
            content: "";
            position: absolute;
            z-index: 1000;
            bottom: -7px;
            left: 50%;
            margin-left: -8px;
            border-top: 8px solid #ddd;
            border-left: 8px solid transparent;
            border-right: 8px solid transparent;
            border-bottom: 0;
        }
        .tooltip span:before
        {
            border-top-color: #ccc;
            bottom: -8px;
        }
        
     
        
    </style>
    
</head>
<body>
    <div id="wrapper">
        <div id="header">
            <h1>                            
                
                Daftar Penyewaan Studio Musik Tanggal <%=request.getParameter("tanggal")%> 
                <%

            int bulan = Integer.parseInt(request.getParameter("bulan"));
            if (bulan == 1) {
                out.println("Januari");
            } else if (bulan == 2) {
                out.println("Februari");
            } else if (bulan == 3) {
                out.println("Maret");
            } else if (bulan == 4) {
                out.println("April");
            } else if (bulan == 5) {
                out.println("Mei");
            } else if (bulan == 6) {
                out.println("Juni");
            } else if (bulan == 7) {
                out.println("Juli");
            } else if (bulan == 8) {
                out.println("Agustus");
            } else if (bulan == 9) {
                out.println("September");
            } else if (bulan == 10) {
                out.println("Oktober");
            } else if (bulan == 11) {
                out.println("November");
            } else if (bulan == 12) {
                out.println("Desember");
            }
            out.println(" "+request.getParameter("tahun"));
            %>  </h1>
        </div>
        <%Calendar calz = new GregorianCalendar();%>
        <div id="nav">
            <%if (session.getAttribute("userOnline") == null) {%>
            <ul>
                <li  ><a href="?action=index"> Home User </a></li>
                                
            <li class="selected"><a href="?action=menuUser&month=<%=calz.getTime().getMonth()+1%>&year=<%=calz.getTime().getYear()+1900%>"> Lihat Jadwal </a></li>
                <li><a href="?action=login"> Login</a></li>
            </ul>
            <%} else {%>
            <ul>
                <li class="selected" ><a href="?action=menuUser&month=<%=calz.getTime().getMonth()+1%>&year=<%=calz.getTime().getYear()+1900%>"> Home User </a></li>
                <li><a href="?action=studio"> Tambah Studio</a></li>
                <li><a href="?action=logout"> Logout </a></li>
            </ul>
            <%}%>
        </div>
        <div id="nav2">
            <a href="?action=menuUser&month=<%=calz.getTime().getMonth()+1%>&year=<%=calz.getTime().getYear()+1900%>">Home </a>&#187; Pilih Studio dan Jam 
            
        </div>
        
        <div id="container">
            <% DBConnection conn = new DBConnection();
            String query = "select ID_STUDIO from STUDIO where studio_status='active'";
            ResultSet studioResult = conn.select(query);
            %>
            <%
            if (request.getAttribute("error") != null) {
            %>
            <div id="proses_error">GAGAL ! data yang anda input tidak valid atau belum lengkap</div>
            <%
            }
            %>
            <%Calendar cal = new GregorianCalendar();
            while (studioResult.next()) {%>
            

            <div id="content">
                <table width="100%">
                    <tr>
                        
                        <th colspan="2"> <% out.println(studioResult.getString("ID_STUDIO"));%></th>
                    </tr>
                   
                    <tr>   
                        <td> <b>Jam</b> </td>
                        <td> <b>Status </b></td>
                    </tr>
                    
                    <% int x = 0;
                String jamMulai, jamSelesai;
                for (int jam = 9; jam <= 19; jam++) {
                    x--;%>
                    <tr> 
                        <td><%out.println(jam + ".00");%> - <%out.println((jam + 1) + ".00");%></td>
                        
                        <td> 
                            <%
                        String queryx = "select * from jadwal where id_studio='" + studioResult.getString("ID_STUDIO") + "' AND jam_mulai='" + jam + ".00' AND tanggal='" + request.getParameter("tanggal") + "-" + request.getParameter("bulan") + "-2011' and status_langganan='active'";
                        ResultSet rset = conn.select(queryx);
                        String nama = "";
                        String no_telp = "";
                        while (rset.next()) {

                            jamMulai = rset.getString("JAM_MULAI");
                            jamSelesai = rset.getString("JAM_SELESAI");
                            nama = rset.getString("NAMA_PENYEWA");
                            no_telp = rset.getString("NO_TELP_PENYEWA");
                            x = Integer.parseInt(jamSelesai.substring(0, (jamSelesai.length() - 3))) - Integer.parseInt(jamMulai.substring(0, (jamMulai.length() - 3)));

                        }



                        if (x > 0) {
                            if (session.getAttribute("userOnline") == null) {%>
                            <%=nama%>
                            <%} else {%>
                            <a href="?action=dataPenyewa&notelp=<%=no_telp%>&nama=<%=nama%>&bulan=<%=request.getParameter("bulan")%>&tanggal=<%=request.getParameter("tanggal")%>&jamMulai=<%=jam + ".00"%>&jamSelesai=<%=(jam + 1) + ".00"%>&studio=<%=studioResult.getString("ID_STUDIO")%>&tahun=<%=request.getParameter("tahun")%>" class="tooltip"> <%=nama%> <span>Nomor Telp : <%=no_telp%> </span></a>
                            <%
                                }
                            } else {
                                if (session.getAttribute("userOnline") == null) {%>
                            KOSONG
                            <%} else {%>
                            <a href= "?action=formJadwal&bulan=<%=request.getParameter("bulan")%>&tanggal=<%=request.getParameter("tanggal")%>&jamMulai=<%=jam + ".00"%>&jamSelesai=<%=(jam + 1) + ".00"%>&studio=<%=studioResult.getString("ID_STUDIO")%>&tahun=<%=request.getParameter("tahun")%>">TAMBAH</a>
                            <%}
                        }
                            %>                       
                            
                        </td>
                        
                    </tr>
                    <tr>

                    <% } %>
                                            <% Studio studio = new Studio();
                            studio.getDataById(studioResult.getString("ID_STUDIO"));%>
                            <td></td>
                            <td><a href="" class="tooltip">Detail Studio<span>Jenis :<%=studio.getJenis_studio()%> <br> Harga :<%=studio.getHarga_sewa_studio()%> <br> Detail :<%=studio.getDetail_studio()%></span> </a></td></tr>
                </table>
            </div>
            <% }%>
        </div>
    </div>
    </div>
    
    
    
</body>
</html>
